import json

data = {'a': 1, 'b': 2}
data2 = json.dumps(data)
print(data2)


class Person():
    name = 'jason'
    age = 10

    def __init__(self, grade):
        self.grade = grade

    def keys(self):
        return ('name','age','grade')

    def __getitem__(self, item):
        return getattr(self, item)

b = Person(16)
print(b.__dict__)
person = dict(b)
print(person)

o = json.dumps(b.__dict__)
print(o)
o1 = json.dumps(person)
print(o1)